//
//  JYOrderCell.m
//  JYFarm
//
//  Created by 花花 on 2017/10/16.
//  Copyright © 2017年 花花. All rights reserved.
//

#import "JYOrderCell.h"

@implementation JYOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
 
    self.leftBtn.layer.borderColor = [UIColor colorWithHexString:@"DDDDDD"].CGColor;
    self.leftBtn.layer.borderWidth = 1;
    
    ;
    self.rightBtn.layer.borderColor = [UIColor colorWithHexString:@"62C6B2"].CGColor;
    self.rightBtn.layer.borderWidth = 1;

    
    self.leftBtn.layer.cornerRadius = 15;
    self.leftBtn.layer.masksToBounds = YES;

    self.rightBtn.layer.cornerRadius = 15;
    self.rightBtn.layer.masksToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

/**
 
 JYOrderType_all = 0, // 全部
 JYOrderType_pay = 1,//待付款
 JYOrderType_shipping = 2,//待发货
 JYOrderType_goods = 3,//待收货
 JYOrderType_complete = 4,//已完成
 */
- (void)setModel:(JYOrderModel *)model{

    
    self.totalLabel.text = [NSString stringWithFormat:@"共%zd件商品",arc4random_uniform(100)];
    
    NSString * momey  =  [NSString stringWithFormat:@"￥%zd.00",arc4random_uniform(100)];
    //@"￥10.00";
    //    NSString *yjStr = @"（含押金￥50元）";
    NSString *yjStr =  [NSString stringWithFormat:@"（含押金￥%zd元）",arc4random_uniform(99)];
    
    ;
    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:momey];
    NSDictionary *attributes = @{
                                 NSFontAttributeName:kFont(13),
                                 NSForegroundColorAttributeName:k9Color
                                 };
    NSAttributedString *str = [[NSAttributedString alloc]initWithString:yjStr attributes:attributes];
    [attributedStr appendAttributedString:str];
    self.moneyLabel.attributedText = attributedStr;
    
    self.orderNumberLabel.text =  [NSString stringWithFormat:@"订单号%zd",arc4random_uniform(666888123)];

    if (model.orderType == JYOrderType_pay) { //待付款
        
           self.stateLabel.hidden = YES;
        
           [self.leftBtn setTitle:@"取消订单" forState:UIControlStateNormal];
            self.leftBtn.layer.borderColor = [UIColor colorWithHexString:@"999999"].CGColor;
            self.leftBtn.layer.borderWidth = 1;
        
        [self.rightBtn setTitle:@"去支付" forState:UIControlStateNormal];

    

    }else if (model.orderType == JYOrderType_shipping){ //待发货
    
        self.leftBtn.hidden = YES;
        self.rightBtn.hidden = YES;
   
         self.stateLabel.text = @"预计25日 07：00-09：00到达";
    
    }else if (model.orderType == JYOrderType_goods){ //待收货
        
        self.stateLabel.text = @"预计25日 07：00-09：00到达";
        
        self.leftBtn.layer.borderColor = [UIColor colorWithHexString:@"63C8B3"].CGColor;
        
        [self.leftBtn setTitle:@"评价" forState:UIControlStateNormal];
        
        [self.rightBtn setTitle:@"确认收货" forState:UIControlStateNormal];
        
    
    }else if (model.orderType == JYOrderType_complete){ //已完成

        self.stateLabel.text = @"已完成";
        self.leftBtn.layer.borderColor = [UIColor colorWithHexString:@"63C8B3"].CGColor;
        
        [self.leftBtn setTitle:@"评价" forState:UIControlStateNormal];
        [self.rightBtn setTitle:@"再次购买" forState:UIControlStateNormal];
    
    }else{
    
      
    }

}

@end
